package cn.edu.lzzy.mypractices.entity;

import com.fasterxml.jackson.annotation.JsonManagedReference;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.*;
import java.util.List;

@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class Question extends BaseEntity {
    public int type;
    public String content;
    public String analysis;
    public int ordinal;
    @OneToMany(cascade = CascadeType.PERSIST,mappedBy = "question" )
    public List<Option> options;
    @ManyToOne
    public Chapter chapter;
    @OneToMany(mappedBy = "question")
    public List<Result> results;

    @Transient
    public static final int SINGLE_CHOICE = 0;
    @Transient
    public static final int JUDGEMENT = 1;
    @Transient
    public static final int MULTIPLE_CHOICE = 2;

    @JsonManagedReference
    public List<Result> getResults() {
        return results;
    }

    @JsonManagedReference
    public Chapter getChapter() {
        return chapter;
    }
}